﻿Public Class ThongKeDAO
    Public Shared Function ThongKeNhaCungCap() As DataTable
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "select  NhaCungCap.ncc_Ten, sum(HangHoa.hh_Gia * HangHoa.hh_SoLuong), sum(HangHoa.hh_SoLuong) from HangHoa, NhaCungCap where HangHoa.hh_NhaCungCap = NhaCungCap.ncc_ID group by NhaCungCap.ncc_Ten"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function

    Public Shared Function HetHang() As DataTable
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "select hh_TenHang, hh_SoLuong from HangHoa where hh_SoLuong = 0"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function

    Public Shared Function ThongKeSoLuong(ByVal _ThongKe As ThongKe) As DataTable
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "select HH.hh_TenHang, sum(CTDH.ctdh_SoLuong) as SoLuong, sum(CTDH.ctdh_Gia) as TongTien from HoaDon HD, ChiTietDonHang CTDH, HangHoa HH where HD.hd_ID = CTDH.ctdh_HoaDon and CTDH.ctdh_TenHang = HH.hh_ID and MONTH(HD.hd_Ngay) = '" & _ThongKe.Thang & "' and year(HD.hd_Ngay) = '" & _ThongKe.Nam & "' group by HH.hh_TenHang"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function


End Class
